//
// Created by xili on 2024/8/22 14:10.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int maximumGroups(vector<int> &grades) {
        int n = grades.size();
        int ans = 0;
        int l = 1, r = n;
        while (l < n) {
            int m = (l + r) >> 1;
            int need = (1 + m) * m / 2;
            if (need > n) {
                r = m - 1;
            } else {
                ans = m;
                l = m + 1;
            }
        }
        return ans;
    }
};